#include "include\AuroraTypes.hpp"

namespace AuroraTypes
{

boost::shared_ptr<Borealis::Raster<float> > GetRaster(VariableList* variables,std::string& key)
{
	AuroraTypes::VariableList::const_accessor a;

	variables->find(a,key);

	if(a.empty())
		throw std::runtime_error("In " + std::string(__FILE__) +" @ line " + boost::lexical_cast<std::string>(__LINE__) +" - key " + key+" does not exist.");

	return boost::dynamic_pointer_cast<Borealis::Raster<float> >(boost::get<boost::shared_ptr<Borealis::VariableBase> >(a->second));

}


int GetInt(VariableList* variables,std::string& key)
{
	AuroraTypes::VariableList::const_accessor a;

	variables->find(a,key);

	if(a.empty())
		throw std::runtime_error("In " + std::string(__FILE__) +" @ line " + boost::lexical_cast<std::string>(__LINE__) +" - key " + key+" does not exist.");

	return boost::get<int>(a->second);
}


float GetFloat(VariableList* variables,std::string& key)
{
	AuroraTypes::VariableList::const_accessor a;

	variables->find(a,key);

	if(a.empty())
		throw std::runtime_error("In " + std::string(__FILE__) +" @ line " + boost::lexical_cast<std::string>(__LINE__) +" - key " + key+" does not exist.");

	return boost::get<float>(a->second);
}

double GetDouble(VariableList* variables,std::string& key)
{
	AuroraTypes::VariableList::const_accessor a;

	variables->find(a,key);

	if(a.empty())
		throw std::runtime_error("In " + std::string(__FILE__) +" @ line " + boost::lexical_cast<std::string>(__LINE__) +" - key " + key+" does not exist.");

	return boost::get<double>(a->second);
}

std::string GetString(VariableList* variables,std::string& key)
{
	AuroraTypes::VariableList::const_accessor a;

	variables->find(a,key);

	if(a.empty())
		throw std::runtime_error("In " + std::string(__FILE__) +" @ line " + boost::lexical_cast<std::string>(__LINE__) +" - key " + key+" does not exist.");

	return boost::get<std::string>(a->second);
}
}